 package org.zlb.algorithm.other;

import java.util.LinkedHashMap;

public class LRULinkedHashMap extends LinkedHashMap<String, Integer> {

    private static final long serialVersionUID = 1L;
    
    private int maxSize;
    
    public LRULinkedHashMap(int maxSize) {
        super((int)(Math.ceil(maxSize / 0.75) + 1), 0.75f, true);
        this.maxSize = maxSize;
    }

    @Override
    protected boolean removeEldestEntry(java.util.Map.Entry<String, Integer> eldest) {
         return size() > maxSize;
    }
    
}
